home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / usr_-_Usr_Files / BIN / LESSPIPE.SH < prev    next >
Linux/UNIX/POSIX Shell Script  |  1999-09-17  |  2KB  |  56 lines

  1. #!/bin/sh
  2. #
  3. # Copyright 1997, 1998 Patrick Volkerding, Moorhead, Minnesota USA
  4. # All rights reserved.
  5. #
  6. # Redistribution and use of this script, with or without modification, is
  7. # permitted provided that the following conditions are met:
  8. #
  9. # 1. Redistributions of this script must retain the above copyright
  10. #    notice, this list of conditions and the following disclaimer.
  11. #
  12. #  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  13. #  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
  15. #  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. #  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17. #  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  18. #  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  19. #  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  20. #  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  21. #  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. #
  23.  
  24. # This is a preprocessor for 'less'.  It is used when this environment
  25. # variable is set:   LESSOPEN="|lesspipe.sh %s"
  26.  
  27. lesspipe() {
  28.   case "$1" in
  29.   *.tar) tar tvvf $1 2>/dev/null ;; # View contents of .tar and .tgz files
  30.   *.tgz) tar tzvvf $1 2>/dev/null ;;
  31.   *.tar.gz) tar tzvvf $1 2>/dev/null ;;
  32.   *.tar.Z) tar tzvvf $1 2>/dev/null ;;
  33.   *.tar.z) tar tzvvf $1 2>/dev/null ;;
  34.   *.tar.bz2) tar tyvvf $1 2>/dev/null ;;
  35.   *.Z) gzip -dc $1  2>/dev/null ;; # View compressed files correctly
  36.   *.z) gzip -dc $1  2>/dev/null ;;
  37.   *.gz) gzip -dc $1  2>/dev/null ;;
  38.   *.bz2) bzip2 -dc $1 2>/dev/null ;;
  39.   *.zip) unzip -l $1 2>/dev/null ;;
  40.   *.1|*.2|*.3|*.4|*.5|*.6|*.7|*.8|*.9|*.n|*.man) FILE=`file -L $1` ; # groff src
  41.     FILE=`echo $FILE | cut -d ' ' -f 2`
  42.     if [ "$FILE" = "troff" ]; then
  43.       groff -s -p -t -e -Tascii -mandoc $1
  44.     fi ;;
  45. #  *) FILE=`file -L $1` ; # Check to see if binary, if so -- view with 'strings'
  46. #    FILE1=`echo $FILE | cut -d ' ' -f 2`
  47. #    FILE2=`echo $FILE | cut -d ' ' -f 3`
  48. #    if [ "$FILE1" = "Linux/i386" -o "$FILE2" = "Linux/i386" \
  49. #         -o "$FILE1" = "ELF" -o "$FILE2" = "ELF" ]; then
  50. #      strings $1
  51. #    fi ;;
  52.   esac
  53. }
  54.  
  55. lesspipe $1
  56.